<template>
    <div>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td align="right">账号</td>
                    <td><input type="text" v-model="info.adminName"></td>
                </tr>
                <tr>
                    <td align="right">密码</td>
                    <td><input type="password" v-model="info.adminpwd"></td>
                </tr>
                <tr>
                    <td align="right"></td>
                    <td><input type="button" value="登录" @click="login"></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { ref, reactive } from 'vue'
import axios from 'axios';
import { useStore } from '@/stores/user'
import { useRouter } from 'vue-router';
const router = useRouter();
const abc = useStore();

let info: any = reactive({
    adminName: '',
    adminpwd: ''
})
const login = () => {
    if (info.adminName == '') {
        alert('账号不能为空')
        return;
    }
    if (info.adminpwd == '') {
        alert('密码不能为空')
        return;
    }
    axios({
        url: '/api/Memder/Login',
        method: 'get',
        params: info
    })
        .then((res) => {
            console.log(res);
            if (res.data == -1) {
                alert("账号错误");
                return;
            }
            if (res.data == -2) {
                alert("密码错误");
                return;
            }

            alert("登陆成功");
            abc.UserIndo = res.data;
            router.push('/loginshow')
            return;


        })
        .catch((err) => {
            console.log(err);

        })
}
</script>

<style scoped></style>